package com.sinven.daoImpl;

import com.sinven.dao.ChannelDao;
import com.sinven.entity.Channel;
import org.hibernate.Session;
import org.hibernate.SessionFactory;
import org.hibernate.query.Query;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.orm.hibernate5.HibernateTemplate;
import org.springframework.orm.hibernate5.support.HibernateDaoSupport;
import org.springframework.stereotype.Repository;

import java.util.List;
@Repository("ChannelDao")
public class ChannelDaoImpl implements ChannelDao {
    @Autowired
    @Qualifier("hibernateTemplate")
    private HibernateTemplate hibernateTemplate;

    @Autowired
    @Qualifier("sessionFactory")
    private SessionFactory sessionFactory;
    @Override
    public List<Channel> listChannel(String hql) {
        Session currentSession = sessionFactory.getCurrentSession();
        Query query = currentSession.createQuery(hql);
        return query.list();
    }
}
